https://leetcode.cn/problems/combination-sum/
class Solution {
public:
    vector<vector<int>> ret;
    vector<int> path;
    int _t;

    void dfs(vector<int>& candidates ,int pathsum,int pos)
    {
        if(pathsum>_t)
            return ;
        if(pathsum==_t || pos>candidates.size())
        {
            ret.push_back(path);
            return ;
        }

        for(int i=pos;i<candidates.size();i++)
        {
            path.push_back(candidates[i]);
            dfs(candidates,pathsum+candidates[i],i);
            path.pop_back();
        }
    }


    vector<vector<int>> combinationSum(vector<int>& candidates, int target) {
        _t=target;
        dfs(candidates,0,0);    
        return ret;
    }
};